<%@ taglib uri="/WEB-INF/myfaces_html.tld" 	prefix="h" %>
<%@ taglib uri="/WEB-INF/myfaces_core.tld" 	prefix="f" %>
<%@ taglib uri="/WEB-INF/tomahawk.tld"     	prefix="t" %>
<%@ page import="java.util.ArrayList" %>

<f:view>
    <jsp:include page="/intestazione.jsp">
        <jsp:param name="titolo" value="Gestione Comune"/>
    </jsp:include>
    <jsp:include page="/menu.jsp"/>
    <script language="javascript" src="./script/popup_full_center.js"></script>
    <script language="javascript" src="./script/confirmCM.js"></script>    
          
    <br />
    <table class="find" style="border: 2pt solid white; margin-bottom: -10px">
        <hr />
        <tr>  
            <td class="intestazionePagina" align="center">
            <strong>GESTIONE COMUNI</strong></td>                        
        </tr>        
    </table>
    
    <t:saveState value="#{beanComune}"/>
    <h:form binding="#{dettaglioComune.form}" id="formLookup">    
        <table class="dettaglio">  
            <tbody>          
            <tr>                   
                <td class="etichettaDettaglio"><strong><t:outputLabel for="codice" value="Codice Comune (*)"/></strong></td>
                <td><t:inputText id="codice" value="#{beanComune.codice}" size="10" maxlength="8" styleClass="dettaglio_InputText" immediate="true" disabled="false"/></td>
            </tr>              

            <tr>                   
                <td class="etichettaDettaglio"><strong><t:outputLabel for="descrizione" value="Descrizione"/></strong></td>
                <td><t:inputText id="descrizione" value="#{beanComune.descrizione}"  size="75" maxlength="100"  styleClass="dettaglio_InputText" onchange="this.value=this.value.toUpperCase()"/>
                <h:message style="color: red" for="descrizione" showDetail="true" showSummary="false" /></td>
            </tr>   
            
           
            <tr>
            <td class="etichettaDettaglio"><strong><t:outputLabel for="codbelfiore" value="Cod. Belfiore" /></strong></td>
            <td><t:inputText id="codbelfiore" value="#{beanComune.codbelfiore}" size="5" maxlength="4" required="false" styleClass="dettaglio_InputText"/>
                <h:message style="color: red" for="codbelfiore" showDetail="true" showSummary="false" />
            </td>
            <tr>
                <td class="etichettaDettaglio"><strong><t:outputLabel for="cap" value="C.A.P. (*)" /></strong></td>
                <td><t:inputText id="cap" value="#{beanComune.cap}" size="6" maxlength="5" required="true" styleClass="dettaglio_InputText"/>
                    <h:message style="color: red" for="cap" showDetail="true" showSummary="false" />
                </td>
            </tr>            
        
            <tr>
                <td class="etichettaDettaglio"><strong>
                    <t:outputLabel for="descrizioneRegione" value="Provincia" />
                </strong></td>
                <td colspan="2">
                    <t:inputText id="codiceProvincia" maxlength="5" value="#{beanComune.beanProvincia.codice}" size="10" styleClass="dettaglio_InputText" disabled="true"/>

                    <t:inputText id="descrizioneProvincia" value="#{beanComune.beanProvincia.descrizione}"  onchange="submit()" valueChangeListener="#{dettaglioComune.lookUp}" size="66" styleClass="dettaglio_InputText">
                        <f:attribute name="nomeBean" value="beanProvincia" />
                        <f:attribute name="nomeBeanLookUp" value="Provincia" />
                    </t:inputText>
                    <br/>
                    <h:message style="color: red" for="descrizioneProvincia" showDetail="false" showSummary="true" />
                </td>       
                <td>                
                    <t:commandLink id="cercaLookup" onclick="loadurl('lookup/lookupProvince.jsf?lookup=descrizioneProvincia');" immediate="true" >
                        <t:graphicImage url="image/system-search.png" border="0" title="Cerca Elemento"/>
                    </t:commandLink>
                </td>    
            </tr>            
            
        </table>
        <br/>
     
        <t:inputHidden value="#{beanComune.id}"/>
        <table bgcolor="#FFFFFF" width="750px">
            <tr>     
                <td>
                    <h:commandLink styleClass="commandLink_Style" dir="RTL" action="benvenuto" immediate="true">
                        <t:graphicImage url="/image/go-home.png" border="0"/>
                    </h:commandLink>              
                </td>   
                <td>
                    <t:commandLink action="#{dettaglioComune.primo}"  rendered="#{beanComune.id ne null}">
                        <t:graphicImage url="image/primo.png" border="0" title="Vai al primo elemento"/>
                        <f:param name="bean" value="beanComune"/>                        
                        <f:param name="id" value="#{beanComune.id}"/>                 
                    </t:commandLink>
                </td>
                <td>
                    <t:commandLink action="#{dettaglioComune.precedente}" rendered="#{beanComune.id ne null}">
                        <t:graphicImage url="image/indietro.png" border="0" title="Indietro"/>
                        <f:param name="bean" value="beanComune"/>                        
                        <f:param name="id" value="#{beanComune.id}"/>                 
                    </t:commandLink>
                </td>
                <td>
                    <t:commandLink action="#{dettaglioComune.successivo}" rendered="#{beanComune.id ne null}">
                        <t:graphicImage url="image/avanti.png" border="0" title="Avanti"/>
                        <f:param name="bean" value="beanComune"/>                        
                        <f:param name="id" value="#{beanComune.id}"/>                 
                    </t:commandLink>
                </td>
                <td>
                    <t:commandLink action="#{dettaglioComune.ultimo}" rendered="#{beanComune.id ne null}">
                        <t:graphicImage url="image/ultimo.png" border="0" title="Vai all'ultimo elemento"/>
                        <f:param name="bean" value="beanComune"/>                        
                        <f:param name="id" value="#{beanComune.id}"/>                 
                    </t:commandLink>
                </td>
              
                <td>
                    <h:commandLink dir="RTL" onmousedown="return confirmDelete(this);" title="cancella" action="#{dettaglioComune.cancella}" rendered="#{beanComune.id ne null}">
                        <t:graphicImage url="image/stop.png" border="0" title="Cancella"/>
                        <f:param name="bean" value="beanComune" />
                    </h:commandLink>                
                </td>                               
                <td>
                    <h:commandLink dir="RTL" onmousedown="return confirmUpdate(this);" title="modifica" action="#{dettaglioComune.modifica}" rendered="#{beanComune.id ne null}">
                        <t:graphicImage url="image/salva.png" border="0" title="Salva modifiche"/>
                        <f:param name="bean" value="beanComune" />
                    </h:commandLink>                
                </td>    

                <td>
                    <h:commandLink dir="RTL" onmousedown="return confirmSave(this);" title="salva inserimento" action="#{dettaglioComune.inserisci}" rendered="#{beanComune.id eq null}">
                        <t:graphicImage url="image/salva.png" border="0" title="Salva inserimento"/>
                        <f:param name="bean" value="beanComune" />
                    </h:commandLink>                
                </td>
                <%--
                <td>
                <h:commandLink dir="RTL" title="Annulla operazione" action="#{dettaglioComune.annulla}" rendered="#{beanComune.id eq null}" immediate="true">
                <t:graphicImage url="image/delete.png" border="0"/>
                <f:param name="bean" value="beanComune" />
                </h:commandLink>                     
                </td>
                --%>
                <td>
                    <h:commandLink dir="RTL" title="inserisce nuovo elemento" action="#{dettaglioComune.inserisciDettaglio}" rendered="#{beanComune.id ne null}">
                        <t:graphicImage url="image/nuovo.png" border="0" title="Inserisci NUOVO"/>
                        <f:param name="bean" value="beanComune" />
                    </h:commandLink>
                </td>
                
                <td>
                    <h:commandLink  title="LISTA" id="lista" action="#{dettaglioComune.lista}" rendered="#{beanComune.id ne null}">
                        <t:graphicImage url="image/lista.png" border="0" title="Carica lista" style="width:32px; height:32px"/>
                        <f:param name="bean" value="Comune" />
                    </h:commandLink>
                </td> 
         
                <td>                
                    <t:commandLink id="cerca1" onclick="loadurl('pages_ricerca/ricercaComuni.jsf');" immediate="true" rendered="#{beanComune.id ne null}">
                        <t:graphicImage url="image/find.png" border="0" title="Cerca Elemento" style="width:32px; height:32px"/>
                    </t:commandLink>
                </td>   
  
                <td>                
                    <t:commandLink id="aiuto" onclick="loadurl('info/legendaBottoniDettaglio.jsf');" immediate="true">
                        <t:graphicImage url="image/help.png" border="0" title="Aiuto"/>
                    </t:commandLink>
                </td> 
            </tr>
        </table>
    </h:form> 
   
    <h:form id="erroriDataBase" rendered="false">
        <f:verbatim><table><td align="left" class="messaggiErrore" height="2px"></f:verbatim>           
        <h:messages style="color: red" showDetail="true" showSummary="false"/>
        <f:verbatim></td></table></f:verbatim>
    </h:form>     
    
    <jsp:include page="/piePagina.jsp"/>      
</f:view>